package com.hello.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hello.common.log.annotation.Log;
import com.hello.common.log.enums.BusinessType;
import com.hello.common.security.annotation.RequiresPermissions;
import com.hello.system.domain.DeviceStatusLog;
import com.hello.system.service.IDeviceStatusLogService;
import com.hello.common.core.web.controller.BaseController;
import com.hello.common.core.web.domain.AjaxResult;
import com.hello.common.core.utils.poi.ExcelUtil;
import com.hello.common.core.web.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 设备状态记录Controller
 * 
 * @author hello
 * @date 2025-09-09
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/deviceStatusLog")
public class DeviceStatusLogController extends BaseController
{
    private final IDeviceStatusLogService deviceStatusLogService;

    /**
     * 查询设备状态记录列表
     */
    @RequiresPermissions("system:deviceStatusLog:list")
    @GetMapping("/list")
    public TableDataInfo list(DeviceStatusLog deviceStatusLog)
    {
        startPage();
        List<DeviceStatusLog> list = deviceStatusLogService.selectDeviceStatusLogList(deviceStatusLog);
        return getDataTable(list);
    }

    /**
     * 导出设备状态记录列表
     */
    @RequiresPermissions("system:deviceStatusLog:export")
    @Log(title = "设备状态记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeviceStatusLog deviceStatusLog)
    {
        List<DeviceStatusLog> list = deviceStatusLogService.selectDeviceStatusLogList(deviceStatusLog);
        ExcelUtil<DeviceStatusLog> util = new ExcelUtil<DeviceStatusLog>(DeviceStatusLog.class);
        util.exportExcel(response, list, "设备状态记录数据");
    }

    /**
     * 获取设备状态记录详细信息
     */
    @RequiresPermissions("system:deviceStatusLog:query")
    @GetMapping(value = "/{logId}")
    public AjaxResult getInfo(@PathVariable("logId") Long logId)
    {
        return success(deviceStatusLogService.selectDeviceStatusLogByLogId(logId));
    }

    /**
     * 新增设备状态记录
     */
    @RequiresPermissions("system:deviceStatusLog:add")
    @Log(title = "设备状态记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeviceStatusLog deviceStatusLog)
    {
        return toAjax(deviceStatusLogService.insertDeviceStatusLog(deviceStatusLog));
    }

    /**
     * 修改设备状态记录
     */
    @RequiresPermissions("system:deviceStatusLog:edit")
    @Log(title = "设备状态记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeviceStatusLog deviceStatusLog)
    {
        return toAjax(deviceStatusLogService.updateDeviceStatusLog(deviceStatusLog));
    }

    /**
     * 删除设备状态记录
     */
    @RequiresPermissions("system:deviceStatusLog:remove")
    @Log(title = "设备状态记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logIds}")
    public AjaxResult remove(@PathVariable Long[] logIds)
    {
        return toAjax(deviceStatusLogService.deleteDeviceStatusLogByLogIds(logIds));
    }
}
